//package com.yonyou.gmmc.common.aop;
//
//import java.lang.reflect.Method;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
//import com.dianping.cat.Cat;
//import com.dianping.cat.message.Transaction;
//import com.yonyou.gmmc.common.annotation.CatTransaction;
//
//@Component
//@Aspect
//public class CatAspect {
//	
//	Logger log = LoggerFactory.getLogger(CatAspect.class);
//
//	public CatAspect() {
//		super();
//		log.debug("cat aop初始化");
//	}
//
//	/**
//	 * 监控CatTransaction注解的内容
//	 * 
//	 * @param joinPoint
//	 * @return
//	 * @throws Throwable
//	 */
//	@Around("@annotation(com.yonyou.gmmc.common.annotation.CatTransaction)")
//	public Object CatTransactionWatch(ProceedingJoinPoint joinPoint) throws Throwable {
//
//		log.debug("进入CatTransaction的监控");
//		
//		Class<? extends Object> object = joinPoint.getTarget().getClass();
//		String methodName = joinPoint.getSignature().getName();
//		log.info("methodName====="+methodName);
//		Method[] methods = object.getMethods();
//		Method method = null;
//		for (Method m : methods) {
//			if (m.getName().equals(methodName)) {
//				method = m;
//			}
//		}
////		Object[] args = joinPoint.getArgs();
////		Class[] parameterTypes = new Class[args.length];
////		for (int i = 0; i < args.length; i++) {
////			parameterTypes[i] = args[i].getClass();
////		}
////		log.info("parameterTypes====="+parameterTypes);
////		method = object.getMethod(methodName, parameterTypes);
//
//		CatTransaction catTransaction = method.getAnnotation(CatTransaction.class);
//		
//		String type = object.getSimpleName(); 	//对应cat中的类型 用类名
//		String name = type + "." + methodName; 	//对应cat中的具体名字 用方法名
//		// String transName =
//		// joinPoint.getSignature().getDeclaringType().getSimpleName() + "." +
//		// joinPoint.getSignature().getName();
//
//		if (!catTransaction.name().equals("")) { //如果注解中有传递则用注解的
//			log.info(catTransaction.name());
//			name = catTransaction.name();
//		}
//
//		if (!catTransaction.type().equals("")) {	//如果注解中有传递则用注解的
//			log.info(catTransaction.type());
//			type = catTransaction.type();
//		}
//
//		Transaction t = Cat.newTransaction(type, name);	//开启一个监控
//		try {
//			Object result = joinPoint.proceed();
//			t.setStatus(Transaction.SUCCESS);
//			return result;
//		} catch (Throwable e) {
//			t.setStatus(e);
//			throw e;
//		} finally {
//			t.complete();
//		}
//	}
//
//	
//}